home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / adasmall / atest1.ada < prev    next >
Text File  |  1996-01-30  |  2KB  |  71 lines

  1. --  This test program is used to simulate a user communicating
  2. --  to a computer center remotely by a terminal.  If the user
  3. --  does not type anything on the terminal for a long time, then
  4. --  the connection is terminated.  So if the user was given high
  5. --  priority and he wakes up just before he is dissconnected then
  6. --  he will be given the CPU and thus won't lose the connection
  7.  
  8. with SMALL_SP; use SMALL_SP;
  9. procedure TERMINAL is
  10.  
  11.    task USER is
  12.    end USER;
  13.  
  14.    task HP is
  15.      entry Communicate;
  16.    end HP;
  17.  
  18.  
  19.    task ANOTHER is
  20.    end ANOTHER;
  21.  
  22.  
  23.    task body USER is
  24.      k : INTEGER;
  25.    begin
  26.        for k in 0..100 loop
  27.          PUT("I'm the user and I'll type something");
  28.          NEW_LINE;
  29.          HP.Communicate;
  30.          PUT("I'm the user and now I'll sleep a while");
  31.          NEW_LINE;
  32.          delay 0.27;
  33.        end loop;
  34.    end USER;
  35.  
  36.  
  37.    task body HP is
  38.      k : INTEGER;
  39.    begin
  40.      for k in 0..100 loop
  41.        delay 0.15;
  42.        select
  43.          accept Communicate do
  44.            PUT("User is up and typing");
  45.            NEW_LINE;
  46.          end Communicate;
  47.        or
  48.          delay 0.29;
  49.          PUT("User is scratching his head, I'll disconnect");
  50.          NEW_LINE;
  51.        end select;
  52.      end loop;
  53.   end HP;
  54.  
  55.  
  56.   task body ANOTHER is
  57.    k : INTEGER;
  58.   begin
  59.     for k in 0..100 loop
  60.       PUT("This is just another user working");
  61.       NEW_LINE;
  62.       if (k mod 10 = 0) then
  63.         delay 0.1;
  64.       end if;
  65.     end loop;
  66.   end ANOTHER;
  67.  
  68. begin
  69.  
  70. end TERMINAL;
  71.